import requests
from config import url_cloud, headers_web


class ClassroomAppointment:
    def __init__(self):
        self.url = url_cloud
        self.headers = headers_web

    @classmethod
    def post_audit_classroom_appointment(cls, url_path: str, headers=headers_web, params=None, json=None):
        """
        @summary:审核教室预约
        @description:云课堂web管理端
        :param url_path:
        :param headers:
        :param params:validCode:验证码（&signKey=123123）
        :param json:body:{
                            "appointmentStatus":"", # operationRemark
                            "classroomAppointmentIds":"", # 教室预约申请单id(多个用“,”隔开)
                            "operationId":"", # 操作人Id
                            "operationName":"", # 操作人名称
                            "operationRemark":"" # 操作备注
                            }
        :return:object:{
                        "message":""
                        }
        """
        url_path = url_path + "/teachinglaboratoryapi/v1/classroomappointment/auditclassroomappointment"
        r = requests.post(url=url_path, headers=headers, params=params, json=json)
        return r

    @classmethod
    def post_cancel_classroom_appointment(cls, url_path: str, headers=headers_web, params=None, json=None):
        """
        @summary:审核教室预约
        @description:云课堂web管理端
        :param url_path:
        :param headers:
        :param params: {
                        "classroomappointmentIds":"", # 教室预约申请单id(多个用“,”隔开)
                        "operationId":"", # 操作人Id
                        "operationName":"", # 操作人名称
                        "operationRemark":"", # 操作备注
                        "operationRole":"", # 操作人身份（0：管理员；1：老师）
                        "validCode":"", #验证码（operationId=XXX&signKey=123123）
                        }
        :param json: null
        :return:
        """
        url_path = url_path + "/teachinglaboratoryapi/v1/classroomappointment/cancelclassroomappointment"
        r = requests.post(url=url_path, headers=headers, params=params, json=json)
        return r

    @classmethod
    def get_check_audit_classroom_appointment(cls, url_path: str, headers=headers_web, params=None):
        """
        @summary:校验审核教室预约是否合法
        @description:云课堂web管理端
        :param url_path:
        :param headers:
        :param params:{
                        "classroomAppointmentIds":"", # 教室预约申请单id(多个用“,”隔开)
                        "validCode":"" # 验证码（&signKey=123123）
                        }
        :return:
        """
        url_path = url_path + "/teachinglaboratoryapi/v1/classroomappointment/checkauditclassroomappointment"
        r = requests.get(url=url_path, headers=headers, params=params)
        return r

    @classmethod
    def get_check_cancel_audit_classroom_appointment(cls, url_path: str, headers=headers_web, params=None):
        """
        @summary:校验取消教室预约（管理员、老师）
        @description:云课堂web管理端
        :param url_path:
        :param headers:
        :param params:{
                        "classroomAppointmentIds":"", # 教室预约申请单id(多个用“,”隔开)
                        "validCode":"", # 验证码（&signKey=123123）
                        "operationRole":"" # 操作人身份（0：管理员；1：老师）
                        }
        :return:
        """
        url_path = url_path + "/teachinglaboratoryapi/v1/classroomappointment/checkcancelclassroomappointment"
        r = requests.post(url=url_path, headers=headers, params=params)
        return r


    @classmethod
    def get_classroom_appointment_details(cls, url_path: str, headers=headers_web, params=None):
        """
        @summary:获取教室预约详情
        @description:云课堂web管理端
        :param url_path:
        :param headers:{
                        "classroomAppointmentIds":"", # 教室预约申请单id(多个用“,”隔开)
                        "validCode":"", # 验证码（classroomAppointmentId=XX&signKey=123123）
                        }
        :param params:
        :return:object:{
                        "activityName":"", # 活动名称
                        "activityRemark":"", # 活动备注信息
                        "applicantId":"", # 申请人id
                        "applicantName":"", # 申请人员名称
                        "applicantNo":"", # 申请人员编号
                        "appointmentApplicationNumber":"", # 活动编号
                        "appointmentEndTime":"", # 申请结束时间
                        "appointmentStartTime":"", # 申请开始时间
                        "appointmentStatusIndex":"", # 活动状态下标
                        "appointmentStatusName":"", # 活动状态名称
                        "createTime":"", # 创建时间（申请时间）
                        "modifierName":"", # 修改人（操作人）
                        "modifyTime":"",# 修改时间（操作时间）
                        "operationRemark":"", # 操作信息（审核/取消备注信息）
                        "phone":"", # 教师联系电话
                        "recordStatus":"", # 开启录制状态（true：开启视频录制；false：关闭视频录制）
                        "appointmentClassroomList":[{ # 预约教室信息
                                  "ClassroomDeviceList":"", # 预约教室设备信息
                                  "classroomCode":"", # 教室编号
                                  "classroomId":"", # 教室Id
                                  "classroomName":"" # 教室名称
                        }]
                        }
        """
        url_path = url_path + "/teachinglaboratoryapi/v1/classroomappointment/classroomappointmentdetails"
        r = requests.get(url=url_path, headers=headers, params=params)
        return r

    @classmethod
    def post_classroom_appointment_info(cls, url_path: str, headers=headers_web, params=None, json=None):
        """
        @summary:获取教室预约申请单信息（管理员、老师）
        @description:云课堂web管理端
        :param url_path:
        :param headers:
        :param params:validCode:验证码（&signKey=123123）
        :param json:body:{
                            "applicantName":"", # 申请人名称模糊查询（管理端使用）
                            "appointmentEndTime":"", # 预约结束时间（格式：yyyy-MM-dd HH:mm；管理端、老师端使用）
                            "appointmentStartTime":"", # 预约开始时间（格式：yyyy-MM-dd HH:mm；管理端、老师端使用）
                            "appointmentStatusIndex":"", # 预约状态下标（管理端、老师端使用）
                            "classroom":"", # 教室名称模糊查询（管理端使用）
                            "classroomOrActivityName":"", # 活动名称或教室模糊查询（老师端使用）
                            "page":"", # 当前页
                            "pageSize":"", # 每页个数
                            "source":"", # 来源：-1：全部 0：web端 1：小程序
                            "teacherId":"",# 老师Id（为空这查询全部；老师端使用）
                            }
        :return:
        """
        url_path = url_path + "/teachinglaboratoryapi/v1/classroomappointment/classroomappointmentlist"
        r = requests.post(url=url_path, headers=headers, params=params, json=json)
        return r

    @classmethod
    def get_classroom_appointment_status(cls, url_path: str, headers=headers_web, params=None):
        """
        @summary:获取教室预约申请单状态
        @description:云课堂web管理端
        :param url_path:
        :param headers:
        :param params:validCode:验证码（&signKey=123123）
        :return:object:{
                        "statusIndex":"", # 状态值
                        "statusName":"", # 状态名称
                        }
        """
        url_path = url_path + "/teachinglaboratoryapi/v1/classroomappointment/classroomappointmentstatus"
        r = requests.get(url=url_path, headers=headers, params=params)
        return r

    @classmethod
    def post_submit_classroom_appointment(cls, url_path: str, headers=headers_web, params=None, json=None):
        """
        @summary:提交教室预约申请
        @description:云课堂web管理端
        :param url_path:
        :param headers:
        :param params:{
                        'classroomAppointmentType':'', # 教室预约类型：0：老师教室预约；1：管理员正常教室预约；2：管理员补登记教室预约
                        'confirmSubmit':'', # 管理员学生预约冲突确认提交：true
                        'confirmSubmitRecording':'', # 管理员录制任务冲突确认提交：true
                        'phone':'', # 教师联系电话
                        'validCode':'' # 验证码（&signKey=123123）
                        }
        :param json:body:{
                            'activityName':'', # 活动名称
                            'activityRemark':'', # 活动备注信息
                            'applicantId':'', # 申请人id
                            'applicantName':'', # 申请人员名称
                            'applicantNo':'', # 申请人员编号
                            'appointmentEndTime':'', # 申请结束时间
                            'appointmentStartTime':'', # 申请开始时间
                            'recordStatus':'', # 开启录制状态（true：开启视频录制；false：关闭视频录制）
                            'source':'', 预约来源： 0：web端 1:小程序
                            'appointmentClassroomList':[{
                                'classroomCode':'', # 教室编号
                                'classroomId':'', # 教室Id
                                'classroomName':'', # 教室名称
                                'ClassroomDeviceList':[{    # 预约教室设备信息
                                    'deviceId':'',# 设备id
                                    'deviceName':'' # 设备名称
                                    }]
                                }]
                            }
        :return:
        """
        url_path = url_path + "/teachinglaboratoryapi/v1/classroomappointment/creationclassroomappointment"
        r = requests.post(url=url_path, headers=headers, params=params, json=json)
        return r

    @classmethod
    def get_occupation_classroom_appointment_info(cls, url_path: str, headers=headers_web, params=None):
        """
        @summary:获取教室预约占用教室信息
        @description:1、云课堂web、小程序老师端、-教室活动预约
        :param url_path:
        :param headers:
        :param params:{
                        'appointmentEndTime':'', # 预约结束时间（格式：yyyy-MM-dd HH:mm）
                        'appointmentStartTime':'',# 预约开始时间（格式：yyyy-MM-dd HH:mm）
                        'validCode':'', # 验证码（&signKey=123123）
                        }
        :return:
        """
        url_path = url_path + "/teachinglaboratoryapi/v1/classroomappointment/occupationclassroom"
        r = requests.get(url=url_path, headers=headers, params=params)
        return r

    @classmethod
    def get_occupation_classroom_appointment_time(cls, url_path: str, headers=headers_web, params=None):
        """
        @summary:获取教室预约占用时间
        @description:1、云课堂web、小程序老师端、-教室活动预约
        :param url_path:
        :param headers:
        :param params:{
                        'appointmentDate':'', # 预约日期（格式：yyyy-MM-dd）
                        'classroomId':'',# 教室Id
                        'validCode':'', # 验证码（classroomId=XX&signKey=123123）
                        }
        :return:
        """
        url_path = url_path + "/teachinglaboratoryapi/v1/classroomappointment/occupationtime"
        r = requests.get(url=url_path, headers=headers, params=params)
        return r

    @classmethod
    def get_occupation_classroom_appointment_times(cls, url_path: str, headers=headers_web, params=None):
        """
        @summary:获取多个教室预约占用时间
        @description:1、云课堂web、小程序老师端、-教室活动预约
        :param url_path:
        :param headers:
        :param params:{
                        'appointmentDate':'', # 预约日期（格式：yyyy-MM-dd）
                        'classroomId':'',# 教室Id
                        'validCode':'', # 验证码（classroomId=XX&signKey=123123）
                        }
        :return:object:{
                        'OccupationType':'', # 占用类型（0：学生预约；1：课表；2：教室预约）
                        'endTime':'', # 结束时间（格式：HH:mm）
                        'roomId':'',
                        'roomName':'',
                        'roomNo':'',
                        'startTime':'', # 开始时间（格式：HH:mm）
                        }
        """
        url_path = url_path + "/teachinglaboratoryapi/v1/classroomappointment/occupationtimes"
        r = requests.get(url=url_path, headers=headers, params=params)
        return r
